package sockettest;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端类
 *
 * @author Luka
 * @date 2021/06/05 20:16
 **/
public class Server {
    private ServerSocket server;

    public Server() {
        System.out.println("正在启动服务器...");
        try {
            server = new ServerSocket(8088);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("服务器启动成功...");
    }

    public void start(){
        try {
            Socket socket;
            while (true){
                System.out.println("等待客户连接...");
                socket = server.accept();
                System.out.println("一个客户连接了!");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        Server server = new Server();
        server.start();

    }
}